import requests
from api.global_conf import BASEURL, LOGPATH, CSVPATH
from utils.index import Logs

log = Logs(LOGPATH)


def shopList():
    try:
        res = requests.get(BASEURL + '/api/goods/getGoodsList')
    except Exception as result:
        log.err(f'获取商品列表接口访问失败: /api/goods/getGoodsList \n报错信息: {result}')
    else:
        log.info(f'获取商品列表访问成功: /api/goods/getGoodsList \n返回数据: {res.text}')
        return res


def shopDetail(params):
    try:
        res = requests.get(BASEURL + '/api/goods/getGoodsDetail', params=params)
    except Exception as result:
        log.err(f'获取商品详情接口访问失败: /api/goods/getGoodsDetail \n报错信息: {result}')
    else:
        log.info(f'获取商品详情接口访问成功: /api/goods/getGoodsDetail \n返回数据: {res.text}')
        return res
